﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pg.BioMedics.SDR.Diagnostics
{
    /// <summary>
    /// Static class gathering all performance counters related to 
    /// the observer business logic service
    /// </summary>
    public sealed class ObserverPerformanceCounters
    {
        #region Constants

        private const string CategoryName = "SDR ASR Observer";

        private const string FinishedTasksCounter = "Finished ASR Tasks";
        private const string FailedTasksCounter = "Failed ASR Tasks";
        private const string DisposedTasksCounter = "Disposed ASR Tasks";
        private const string InsertedTokensCounter = "InsertedTokens";
        private const string CheckTimeCounter = "Check Time";

        #endregion

        #region Fields

        private static ObserverPerformanceCounters instance;

        private readonly NumberOfItemsPerformanceCounter finishedTasks = new NumberOfItemsPerformanceCounter(CategoryName, FinishedTasksCounter);
        private readonly NumberOfItemsPerformanceCounter failedTasks = new NumberOfItemsPerformanceCounter(CategoryName, FailedTasksCounter);
        private readonly NumberOfItemsPerformanceCounter disposedTasks = new NumberOfItemsPerformanceCounter(CategoryName, DisposedTasksCounter);
        private readonly NumberOfItemsPerformanceCounter insertedTokens = new NumberOfItemsPerformanceCounter(CategoryName, InsertedTokensCounter);
        private readonly TimingPerformanceCounter checkTime = new TimingPerformanceCounter(CategoryName, CheckTimeCounter);

        #endregion

        #region Constructors

        /// <summary>
        /// Creates instance of the observer counters context accessor
        /// </summary>
        private ObserverPerformanceCounters() { }

        #endregion

        #region Static properties

        /// <summary>
        /// Gets singelton instance of the ObserverCounters class. This
        /// property supports lazy init
        /// </summary>
        public static ObserverPerformanceCounters Instance
        {
            get
            {
                if (instance == null)
                    instance = new ObserverPerformanceCounters();

                return instance;
            }
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets finished ASR tasks counter
        /// </summary>
        public NumberOfItemsPerformanceCounter FinishedTasks
        {
            get
            {
                return this.finishedTasks;
            }
        }

        /// <summary>
        /// Getgs failed ASR tasks counter
        /// </summary>
        public NumberOfItemsPerformanceCounter FailedTasks
        {
            get
            {
                return this.failedTasks;
            }
        }

        /// <summary>
        /// Gets disposed ASR tasks counter
        /// </summary>
        public NumberOfItemsPerformanceCounter DisposedTasks
        {
            get
            {
                return this.disposedTasks;
            }
        }

        /// <summary>
        /// Gets inserted AST tokens counter
        /// </summary>
        public NumberOfItemsPerformanceCounter InsertedTokens
        {
            get
            {
                return this.insertedTokens;
            }
        }

        /// <summary>
        /// Gets ASR tasks check time counter
        /// </summary>
        public TimingPerformanceCounter CheckStatusTiming
        {
            get
            {
                return this.checkTime;
            }
        }

        #endregion
    }
}
